package com.zhanglinwei.openApiServer;

import com.zhanglinwei.openApiClient.client.OpenApiClient;
import com.zhanglinwei.openApiClient.model.entity.CodefyTools;
import com.zhanglinwei.openApiClient.model.request.ExampleGetByCodeListRequest;
import com.zhanglinwei.openApiClient.model.request.ExampleGetByCodeRequest;
import com.zhanglinwei.openApiClient.model.response.api.ExampleGetByCodeListResponse;
import com.zhanglinwei.openApiClient.model.response.api.ExampleGetByCodeResponse;
import com.zhanglinwei.openApiClient.model.response.lambda.ExampleLambdaResponse;
import com.zhanglinwei.openApiClient.wrapper.OpenApiLambdaWrapper;

import java.util.Collections;
import java.util.List;
import java.util.Optional;

public class ApiClientTest {
    public static void main(String[] args) {
        OpenApiClient openApiClient = OpenApiClient.createClient("http://localhost:8090/zlw/openapi/", "xx", "xx");

        ExampleGetByCodeRequest codeRequest = new ExampleGetByCodeRequest();
        codeRequest.setCode("xxx");
        ExampleGetByCodeResponse codeResponse = openApiClient.apiCodeQuery(codeRequest);

        ExampleGetByCodeListRequest codeListRequest = new ExampleGetByCodeListRequest();
        codeListRequest.setCodeList(Collections.singletonList("xxx"));
        ExampleGetByCodeListResponse codeListResponse = openApiClient.apiCodeQuery(codeListRequest);


        OpenApiLambdaWrapper<CodefyTools> wrapper = new OpenApiLambdaWrapper<CodefyTools>()
                .eq(CodefyTools::getCode, "JAVA");

        Optional<ExampleLambdaResponse.ExampleDTO> selectOne1 = openApiClient.selectOne(wrapper, false);
        Optional<ExampleLambdaResponse.ExampleDTO> selectOne2 = openApiClient.selectOne(wrapper);
        List<ExampleLambdaResponse.ExampleDTO> selectedList = openApiClient.selectList(wrapper);
        ExampleLambdaResponse exampleLambdaResponse = openApiClient.selectPage(wrapper);
        List<ExampleLambdaResponse.ExampleDTO> content = exampleLambdaResponse.content();
    }
}
